#ifndef _GLFWWINDOW_H_
#define _GLFWWINDOW_H_

#include "engine.h"
#include "window.h"
#include "scene.h"
#include "ui/imgui_manager.h"
#include "render/render_system.h"

namespace engine
{
    class GlfwWindow : public IWindow
    {
    public:
        // 输入窗口名的构造函数
        GlfwWindow(std::string title);
        // 同时设置窗口名称、位置和大小的构造函数
        GlfwWindow(std::string title, int x, int y, int width, int height);

        bool create() override;
        bool destory() override;
        void loop() override;

    private:
        // 判断窗口是否被创建
        bool isCreated;
        GLFWwindow *m_pGLFWwindow;

        RenderSystem *m_pRenderSystem;
        Scene *m_pScene;

        // 初始化函数
        void init()
        {
            this->setTitle(std::string("未命名窗口"));
            this->setPostion(100, 100);
            this->setSize(800, 600);
            this->isCreated = false;
        }

    public:
        std::string getTitle() override
        {
            return this->title;
        }

        void setTitle(std::string t) override
        {
            this->title = t;
        };

        int getWidth() override
        {
            return this->width;
        }

        int getHeight() override
        {
            return this->height;
        }

        void setPostion(int x, int y) override
        {
            this->left = x;
            this->top = y;
        }

        void setSize(int width, int height) override
        {
            this->width = width;
            this->height = height;
        }

    private:
        std::shared_ptr<UIManager> uiManager;

        void pre_render();
        void render();
        void post_render();
    };
}
#endif /* _GLFWWINDOW_H_ */